/* ---------------------------------------------------------------------------------
|
|  $URL: http://tech2allwptheme.googlecode.com/svn/trunk/js/util.js $
|  $Rev: 6 $
|  $LastChangedDate: 2008-12-16 07:42:28 +0000 (Tue, 16 Dec 2008) $
|  $LastChangedBy: ruhani.rabin $
|  $Id: util.js 6 2008-12-16 07:42:28Z ruhani.rabin $
|
| ---------------------------------------------------------------------------------*/

function Quote(otextarea) {
  var otext = document.getElementById("co_" + otextarea);
  var oauthor = document.getElementById("au_" + otextarea)
  var otextCommentArea = document.getElementById("comment");
  var otextCommentParent = document.getElementById("comment_parent");
  if (window.getSelection)
     var sel = window.getSelection();
  else if (document.getSelection)
     var sel = document.getSelection();
  else if (document.selection) {
     var sel = document.selection.createRange().text; }
  if (otext.innerText){
      if (sel != "") {
			otextCommentArea.value += '<b><a href="#comment-' + otextarea + '">' + oauthor.innerText + '</a></b> Wrote:\n<cite>' + sel + '</cite>';
			otextCommentParent.value = otextarea;
	  }
        else {
			otextCommentArea.value += '<b><a href="#comment-' + otextarea + '">' + oauthor.innerText + '</a></b>  Wrote:\n<cite>' + otext.innerText + '</cite>';
			otextCommentParent.value = otextarea;
		}
  }
  else {
      if (sel != "") {
			otextCommentArea.value += '<b><a href="#comment-' + otextarea + '">' + oauthor.textContent + '</a></b> Wrote:\n<cite>' + sel + '</cite>';
			otextCommentParent.value = otextarea;
	  }
        else {
			otextCommentArea.value += '<b><a href="#comment-' + otextarea + '">' +  oauthor.textContent + '</a></b> Wrote:\n<cite>' + otext.textContent + '</cite>';
			otextCommentParent.value = otextarea;
		}
  }
  otextCommentArea.focus();
}

function Reply(otextarea) {
  var otext = document.getElementById("co_" + otextarea);
  var oauthor = document.getElementById("au_" + otextarea)
  var otextCommentArea = document.getElementById("comment");
  var otextCommentParent = document.getElementById("comment_parent");
  if (window.getSelection)
     var sel = window.getSelection();
  else if (document.getSelection)
     var sel = document.getSelection();
  else if (document.selection) {
     var sel = document.selection.createRange().text; }
  if (otext.innerText){
      if (sel != "") {
			otextCommentArea.value += '<b><a href="#comment-' + otextarea + '"></a>' + oauthor.innerText + '</b>:\n';
			otextCommentParent.value = otextarea;
	  }
        else {
			otextCommentArea.value += '<b>@<a href="#comment-' + otextarea + '">' + oauthor.innerText + '</a></b>,';
			otextCommentParent.value = otextarea;
		}
  }
  else {
      if (sel != "") {
			otextCommentArea.value += '<b><a href="#comment-' + otextarea + '"></a>' + oauthor.textContent + '</b> :';
			otextCommentParent.value = otextarea;
	  }
      else {
			otextCommentArea.value += '<b>@<a href="#comment-' + otextarea + '">' +  oauthor.textContent + '</a></b>,';
			otextCommentParent.value = otextarea;
	  }
  }
  otextCommentArea.focus();
}
